<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('修改泵站')" />
	<th:block th:include="include :: select2-css" />
</head>
<body>
    <div class="form-content">
        <form class="form-horizontal" id="form-stationElement-add" >
            <h4 class="form-header h4">基本信息</h4>
            <input name="stationId" autocomplete="off" id="stationId"  class="form-control" type="hidden"  >
            <div class="row">
            	<div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label"><span style="color: red; ">*</span>编号：</label>
                        <div class="col-sm-8">
                            <input name="serialNumber" id="serialNumber" autocomplete="off" placeholder="请输入组件编号" class="form-control" type="number"   required>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                 <div class="form-group">
                 		<label class="col-sm-4 control-label"><span style="color: red; ">*</span>泵站名称：</label>
                        <div class="col-sm-8">
                            <div class="input-group">
                                <input class="form-control" type="text" name="stationName" onclick="selectPumpStation()" id="stationName"  required>
                            	<span class="input-group-addon"><i class="fa fa-search"></i></span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                 <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">组件类型：</label>
                        <div class="col-sm-8">
                         <div class="input-group " style="width: 100%">
                                <select name="type" id="type" class="form-control m-b" th:with="type=${@dict.getType('biz_se_type')}" required>
				                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" ></option>
				                </select>
                          </div>
                          </div>
                    </div>
                </div>
                 <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">阀门状态：</label>
                        <div class="col-sm-8">
                         <div class="input-group " style="width: 100%">
                                <select name="isOpen" class="form-control m-b" th:with="type=${@dict.getType('biz_is_open')}">
				                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" ></option>
				                </select>
                          </div>
                          </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">是否有效：</label>
                        <div class="col-sm-8">
                         <div class="input-group " style="width: 100%">
                                <select name="isValid" class="form-control m-b" th:with="type=${@dict.getType('biz_is_valid')}">
				                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" ></option>
				                </select>
                          </div>
                          </div>
                    </div>
                </div>
            </div>
            <h4 class="form-header h4">其他信息</h4>
            <div class="row">
                <div class="col-sm-12">
                    <div class="form-group">
                        <label class="col-xs-2 control-label">备注：</label>
                        <div class="col-xs-10">
                            <textarea name="remark" autocomplete="off"   class="form-control" rows="3"></textarea>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
   <!--  <div class="row">
        <div class="col-sm-offset-5 col-sm-10">
            <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
            <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
        </div>
    </div> -->
	<th:block th:include="include :: footer" />
	<th:block th:include="include :: select2-js" />
	<script type="text/javascript">
        var prefix = ctx + "biz/stationElement";
        
        $("#form-stationElement-add").validate({
        	onkeyup: false,
        	rules:{
        		serialNumber:{
                    remote: {
                        url: prefix + "/checkSerialNumberUnique",
                        type: "post",
                        dataType: "json",
                        data: {
                        	"type": function() {
                        		return $("#type").val();
                            },
                			"serialNumber": function() {
                                return $.common.trim($("#serialNumber").val());
                            }
                        },
                        dataFilter: function (data, type) {
                        	return $.validate.unique(data);
                        }
                    }
        		},
        	},
        	messages: {
        		"serialNumber":{
                	remote: "泵组件编号已存在"
        		}
            },
            focusCleanup: true
        }); 
        
        function submitHandler() {
	        if ($.validate.form()) {
	        	var data = $("#form-stationElement-add").serializeArray();
	        	$.operate.save(prefix + "/add", data);
	        }
	    }
        
        
        function selectPumpStation() {
        	var psId = $("#psId").val();
            var url = ctx + "biz/pumpStation/selectPumpStation";
		    var options = {
				title: '选择泵站',
				width: "380",
				url: url,
				callBack: doPumpStationSubmit
			};
			$.modal.openOptions(options);
		}
		
		function doPumpStationSubmit(index, layero){
			var tree = layero.find("iframe")[0].contentWindow.$._tree;
			var body = layer.getChildFrame('body', index);
			$("#stationId").val(body.find('#psId').val());
			$("#stationName").val(body.find('#stationName').val());
			layer.close(index);
		}
       

    </script>
</body>
</html>